## Process this file with automake to produce Makefile.in.

AUTOMAKE_OPTIONS = foreign

# May be used by various substitution variables.
gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)

EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
	   echo $(top_builddir)/../expect/expect; else echo expect; fi)

_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir

PWD_COMMAND = $${PWDCMD-pwd}

EXTRA_DEJAGNU_SITE_CONFIG = libgomp-site-extra.exp

# Instead of directly in ../testsuite/libgomp-test-support.exp.in, the
# following variables have to be "routed through" this Makefile, for expansion
# of the several (Makefile) variables used therein.
libgomp-test-support.exp: libgomp-test-support.pt.exp Makefile
	cp $< $@.tmp
	echo >> $@.tmp \
	  'set offload_additional_options "$(offload_additional_options)"'
	echo >> $@.tmp \
	  'set offload_additional_lib_paths "$(offload_additional_lib_paths)"'
	mv $@.tmp $@

site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
	@echo 'Making a new site.exp file ...'
	@echo '## these variables are automatically generated by make ##' >site.tmp
	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
	@echo '# edit the last section' >>site.tmp
	@echo 'set srcdir "$(srcdir)"' >>site.tmp
	@echo "set objdir `pwd`" >>site.tmp
	@echo 'set build_alias "$(build_alias)"' >>site.tmp
	@echo 'set build_triplet $(build_triplet)' >>site.tmp
	@echo 'set host_alias "$(host_alias)"' >>site.tmp
	@echo 'set host_triplet $(host_triplet)' >>site.tmp
	@echo 'set target_alias "$(target_alias)"' >>site.tmp
	@echo 'set target_triplet $(target_triplet)' >>site.tmp
	@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
	  echo "## Begin content included from file $$f.  Do not modify. ##" \
	   && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
	   && echo "## End content included from file $$f. ##" \
	   || exit 1; \
	 done >> site.tmp
	@echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
	@if test -f site.exp; then \
	   sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
	 fi
	@-rm -f site.bak
	@test ! -f site.exp || mv site.exp site.bak
	@mv site.tmp site.exp

%/site.exp: site.exp
	-@test -d $* || mkdir $*
	@srcdir=`cd $(srcdir); ${PWD_COMMAND}`;
	@objdir=`${PWD_COMMAND}`/$*; \
	sed -e "s|^set srcdir .*$$|set srcdir $$srcdir|" \
	    -e "s|^set objdir .*$$|set objdir $$objdir|" \
	    site.exp > $*/site.exp.tmp
	@-rm -f $*/site.bak
	@test ! -f $*/site.exp || mv $*/site.exp $*/site.bak
	@mv $*/site.exp.tmp $*/site.exp

check_p_numbers0:=1 2 3 4 5 6 7 8 9
check_p_numbers1:=0 $(check_p_numbers0)
check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1)))
check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2)
check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3)))
check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4)
check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5)))
check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6)
# If unable to serialize execution testing, use just one parallel slot.
gcc_test_parallel_slots:=$(if $(FLOCK),$(if $(GCC_TEST_PARALLEL_SLOTS),$(GCC_TEST_PARALLEL_SLOTS),19),1)
check_p_subdirs=$(wordlist 1,$(gcc_test_parallel_slots),$(check_p_numbers))
check_DEJAGNU_libgomp_targets = $(addprefix check-DEJAGNUlibgomp,$(check_p_subdirs))
$(check_DEJAGNU_libgomp_targets): check-DEJAGNUlibgomp%: libgomp%/site.exp

check-DEJAGNU $(check_DEJAGNU_libgomp_targets): check-DEJAGNU%: site.exp
	$(if $*,@)AR="$(AR)"; export AR; \
	RANLIB="$(RANLIB)"; export RANLIB; \
	if [ -z "$*" ] && [ -n "$(filter -j%, $(MFLAGS))" ]; then \
	  rm -rf libgomp-parallel || true; \
	  mkdir libgomp-parallel; \
	  $(MAKE) $(AM_MAKEFLAGS) $(check_DEJAGNU_libgomp_targets); \
	  rm -rf libgomp-parallel || true; \
	  for idx in $(check_p_subdirs); do \
	    if [ -d libgomp$$idx ]; then \
	      mv -f libgomp$$idx/libgomp.sum libgomp$$idx/libgomp.sum.sep; \
	      mv -f libgomp$$idx/libgomp.log libgomp$$idx/libgomp.log.sep; \
	    fi; \
	  done; \
	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
	    libgomp[0-9]*/libgomp.sum.sep > libgomp.sum; \
	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
	    libgomp[0-9]*/libgomp.log.sep > libgomp.log; \
	  exit 0; \
	fi; \
	srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
	EXPECT=$(EXPECT); export EXPECT; \
	runtest=$(_RUNTEST); \
	if [ -z "$$runtest" ]; then runtest=runtest; fi; \
	tool=libgomp; \
	if [ -n "$*" ]; then \
	  if [ -f libgomp-parallel/finished ]; then rm -rf "$*"; exit 0; fi; \
	  GCC_RUNTEST_PARALLELIZE_DIR=`${PWD_COMMAND}`/libgomp-parallel; \
	  export GCC_RUNTEST_PARALLELIZE_DIR; \
	  cd "$*"; \
	fi; \
	if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
	  $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
		    $(RUNTESTFLAGS); \
	  if [ -n "$*" ]; then \
	    touch $$GCC_RUNTEST_PARALLELIZE_DIR/finished; \
	  fi; \
	else \
	  echo "WARNING: could not find \`runtest'" 1>&2; :;\
	fi

distclean-DEJAGNU:
	-rm -f site.exp site.bak
	-l='$(PACKAGE)'; for tool in $$l; do \
	  rm -f $$tool.sum $$tool.log; \
	done
distclean-am: distclean-DEJAGNU
check-am:
	@if test -n "$(filter -j%, $(MFLAGS))"; then \
	  num_cpus=@CPU_COUNT@; \
	  if type -p getconf 2>/dev/null >/dev/null; then \
	    num_cpus=`getconf _NPROCESSORS_ONLN 2>/dev/null`; \
	    case "$$num_cpus" in \
	      '' | 0* | *[!0-9]*) num_cpus=@CPU_COUNT@;; \
	    esac; \
	  fi; \
	  if test $$num_cpus -gt 8 && test -z "$$OMP_NUM_THREADS"; then \
	    OMP_NUM_THREADS=8; export OMP_NUM_THREADS; \
	    echo @@@ libgomp OMP_NUM_THREADS adjusted to 8 because of parallel make check and too many CPUs; \
	  fi; \
	fi; \
	$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
all-local: libgomp-test-support.exp

.PHONY: check-DEJAGNU distclean-DEJAGNU
